<template>
	<div v-cloak class="aui-wrapper aui-page__iframe">
		<div class="aui-content__wrapper">
			<div class="aui-content">
				<el-card shadow="never" class="aui-card--fill">
					<div class="mod-lswms__allocationstrategy">
						<el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
							<!--   <el-form-item>
                            <el-input v-model="dataForm.strategykey" placeholder="id" clearable></el-input>
                          </el-form-item> -->
							<el-form-item>
								<el-input v-model="dataForm.strategykey" size="small" placeholder="分配策略号" clearable></el-input>
							</el-form-item>
							<el-form-item>
								<el-input v-model="dataForm.strategykey" size="small" placeholder="分配策名称" clearable></el-input>
							</el-form-item>
							<el-form-item>
								<el-button @click="getDataList()" size="small">查询</el-button>
							</el-form-item>
							<el-form-item>
								<el-button type="primary" @click="addOrUpdateHandle()"  size="small" v-if="hasPermission('lswms:allocationstrategy:save')" >新增</el-button>
							</el-form-item>
							<!-- <el-form-item>
								<el-button type="danger" @click="deleteHandle()">删除</el-button>
							</el-form-item> -->
							<!-- <el-form-item>
                            <el-button type="info" @click="exportHandle()">导出</el-button>
                          </el-form-item> -->
						</el-form>
						<el-table v-loading="dataListLoading" :data="dataList" border
							@selection-change="dataListSelectionChangeHandle" @sort-change="dataListSortChangeHandle"
							style="width: 100%;">
							<!-- <el-table-column type="selection" header-align="center" align="center" width="50">
							</el-table-column> -->
							<!--  <el-table-column prop="id" label="序号"  header-align="center"
                                           align="center"></el-table-column> -->
							<el-table-column prop="strategykey" label="分配策略号" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="strategyname" label="分配策名称" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="strictlotrotation" label="是否严格批周转" header-align="center"
								align="center">
								<template #default="scope">
									<el-checkbox v-model="scope.row.strictlotrotation" disabled></el-checkbox>
								</template>
							</el-table-column>
							<el-table-column prop="overallocatepicks" label="是否允许超分配" header-align="center"
								align="center">
								<template #default="scope">
									<el-checkbox v-model="scope.row.strictlotrotation" disabled></el-checkbox>
								</template>
							</el-table-column>
							<!-- <el-table-column prop="adduser" label="创建人"  header-align="center"
                                           align="center"></el-table-column>
                                                    <el-table-column prop="addtime" label="创建时间"  header-align="center"
                                           align="center"></el-table-column>
                                                    <el-table-column prop="updatuser" label="更新人"  header-align="center"
                                           align="center"></el-table-column>
                                                    <el-table-column prop="updatetime" label="更新时间"  header-align="center"
                                           align="center"></el-table-column> -->
							<el-table-column label='操作' fixed="right" header-align="center" align="center" width="150">
								<template #default="scope">
									<el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.id)"  v-if="hasPermission('lswms:allocationstrategy:update')" >修改 
									</el-button>
									<el-button type="text" size="small" @click="deleteHandle(scope.row.id)"  v-if="hasPermission('lswms:allocationstrategy:delete')" >删除
									</el-button>
									<el-button type="text" size="small"
										@click="listHandle(scope.row.id,scope.row.strategykey)">明细</el-button>
								</template>
							</el-table-column>
						</el-table>
						<el-pagination :current-page="page" :page-sizes="[10, 20, 50, 100]" :page-size="limit"
							:total="total" layout="total, sizes, prev, pager, next, jumper"
							@size-change="pageSizeChangeHandle" @current-change="pageCurrentChangeHandle">
						</el-pagination>
						<!-- 弹窗, 新增 / 修改 -->
						<allocationstrategyAddOrUpdate v-if="addOrUpdateVisible" ref="addOrUpdate"
							@refresh-data-list="getDataList"></allocationstrategyAddOrUpdate>
						<!-- 明细 -->
						<allocationstrategydetail v-if="subpagedetailVisible" ref="subpagedetailvue"></allocationstrategydetail>	
					</div>
				</el-card>
			</div>
		</div>
	</div>
</template>

<script>
	import DataList from "@/utils/DataList";
	import {
		ref,
		reactive,
		onMounted,
		nextTick
	} from 'vue';
	import allocationstrategyAddOrUpdate from "@/components/lswms/base/AllocationstrategyAddOrUpdate";
import allocationstrategydetail  from "@/views/lswms/base/Allocationstrategydetail.vue"
	import {hasPermission} from "@/utils/hasPermission"
	export default {
		name: "allocationstrategy",

		components: {
			allocationstrategyAddOrUpdate,
			allocationstrategydetail
		},

		setup() {
			const {
				dataForm,
				mixinViewModuleOptions,
				getDataList,
				dataList,
				total,
				page,
				limit,
				dataListLoading,
				dataListSelectionChangeHandle,
				dataListSortChangeHandle,
				pageSizeChangeHandle,
				pageCurrentChangeHandle,
				addOrUpdateHandle,
				deleteHandle,
				exportHandle,
				addOrUpdateVisible,
				dataListSelections,
				addOrUpdate
			} = DataList();

			onMounted(() => {
				mixinViewModuleOptions.value.getDataListIsPage = true;
				mixinViewModuleOptions.value.getDataListURL = '/lswms/allocationstrategy/page';
				mixinViewModuleOptions.value.deleteURL = '/lswms/allocationstrategy';
				mixinViewModuleOptions.value.exportURL = '/lswms/allocationstrategy/export';
				mixinViewModuleOptions.value.deleteIsBatchKey = 'id';
				mixinViewModuleOptions.value.deleteIsBatch = true
				if (mixinViewModuleOptions.value.activatedIsNeed) {
					getDataList();
				}

			})

			//打开list页
			const subpagedetailVisible = ref(false);
			const subpagedetailvue = ref(null);
			const listHandle = (id,strategykey) => {
				subpagedetailVisible.value = true;
				nextTick(function() {
					//subpagedetailvue.value.dataForm.id = id;
					subpagedetailvue.value.dataForm.strategykey = strategykey;
					subpagedetailvue.value.init();
				})
			}


			return {
				dataForm,
				mixinViewModuleOptions,
				getDataList,
				dataList,
				total,
				page,
				limit,
				dataListLoading,
				dataListSelectionChangeHandle,
				dataListSortChangeHandle,
				pageSizeChangeHandle,
				pageCurrentChangeHandle,
				addOrUpdateHandle,
				deleteHandle,
				exportHandle,
				addOrUpdateVisible,
				dataListSelections,
				addOrUpdate,
				subpagedetailVisible,
				subpagedetailvue,
				listHandle
			}
		},
		methods:{
			hasPermission
		}
	}
</script>

<style scoped>

</style>
